from typing import Optional

from pydantic import conlist, conint

from services.server_integration.schemas.channel import Channel
from services.server_integration.schemas.enableabl import Enableable
from services.server_integration.schemas.link import Link
from services.services_module.schemas.configs import ModuleType


class Str(Enableable):
    gain: Link[int] = Link[int](ul=0, dl=0)

    carrier_frequency: Link[float] = Link[float](ul=1_850_000_000, dl=1_745_000_000)
    output_power: float = 33.0


class NbSubchannels(Enableable):
    erfsn: float = 0.0
    channels: conlist(conint(ge=0, le=1_949), min_items=4, max_items=4) = [0.0] * 4


class ServiceChannel(Channel):
    min_arfsn: int = 0
    max_arfsn: int = 0
    str: Str = Str()

    nb_subchannels: Optional[NbSubchannels] = NbSubchannels()

    delay: Link[int] = Link[int](ul=0, dl=0)
    cable_loss: Link[int] = Link[int](ul=0, dl=0)
    attenuation: Link[int] = Link[int](ul=0, dl=0)
    frequency_offset: Link[float] = Link[float](ul=2_500_000, dl=2_500_000)

    bandwidth: float = 5000000
    bs_power: float = 0.0

    frequency: Optional[int] = 800
    editable: bool = False
    type: ModuleType = ModuleType.LTE
